#include <iostream>
#include <vector>

class Arrange
{
private:
    /* data */
public:
    Arrange(/* args */){}
    ~Arrange(){}

    void initNum(std::vector<int> &vct){
        for (auto one : vct) {
            insertArrang(one);
        }
    }

    void insertArrang(int value) {
        if (m_vct_arrange.size() == 0) {
            std::vector<int> vct = {value};
            m_vct_arrange.insert(m_vct_arrange.end(), vct);
            return;
        }

        std::vector< std::vector<int> > vct_tmp = m_vct_arrange;
        m_vct_arrange.clear();
        for (int i = 0; i <= vct_tmp.front().size(); i++)
        {
            for (auto one : vct_tmp) {
                m_vct_arrange.insert(m_vct_arrange.end(), one);
                m_vct_arrange.back().insert(m_vct_arrange.back().begin() + i, value);
            }
        }
    }

    std::vector<int> getResult(std::vector<int> &vct){
        int result = INT32_MAX;
        std::vector<int> vct_result;

        for (auto one : m_vct_arrange) {
            int diff = abs(18350 - getResult(vct, one));
            if (diff < result) {
                result = diff;
                vct_result = one;
            }
        }

        return vct_result;
    }

    void vctPrint() {
        for (auto vct : m_vct_arrange) {
            for (auto one : vct) {
                printf("%02d, ", one);
            }
            printf("\n");
        }
    }

private:
    std::vector< std::vector< int > > m_vct_arrange;

    int getResult(std::vector<int> &vct1, std::vector<int> &vct2) {

        int sum = 0;
        for (int i = 0; i < vct1.size(); i++) {
            int diff = abs(vct1[i] - vct2[i]);
            sum += diff * diff;
        }

        return sum;
    }
};